<?php
/**
 * A view file for JavaScript JSON requests
 * @author Erko Risthein <erko@risthein.ee>
 * @copyright Copyright (C) 2009 Erko Risthein
 * @link http://erko.risthein.ee/decode/
 * @license http://www.gnu.org/licenses/ GNU General Public License
 * @package decode_explorer
 */

//Other stuff
$other_json[] = array(
	'breadcrumb' => $breadcrumb,
	'name_sort_url' => $name_sort_url,
	'size_sort_url' => $size_sort_url,
	'date_sort_url' => $date_sort_url,
	'parent_folder' => $parent_folder,
	'total_objects' => $total_objects,
	'total_size' => $total_size
);

//Folders
$folders_json = array();
foreach ($folders as $folder) {
	$folders_json[] = array(
		'url' => $folder->get_url(),
		'name' => $folder->get_name(),
		'date' => $folder->get_date()
	);
}

//Files
$files_json = array();
foreach ($files as $file) {
	$files_json[] = array(
		'icon' => $file->get_icon(),
		'url' => $file->get_url(),
		'name' => $file->get_name(),
		'size' => $file->get_size(),
		'size_in_bytes' => $file->get_size_in_bytes(),
		'date' => $file->get_date()
	);
}

//The summarizing JSON array
$json = array(
	'other' => $other_json,
	'folders' => $folders_json,
	'files' => $files_json
);

echo json_encode($json);
?>